#include "stdafx.h"

int main_t(HINSTANCE hInstance, int argc, TCHAR* argv[])
{
	string basic_class_iid;
	basic_class_iid.clear();
	basic_class_iid.append("//");
	char szTemp[4096] = {0x00};
#if (TARGET_OS == OS_WINDOWS)
	sentry<char*, default_array_sentry> pBuf = ucs2_to_char(argv[1], s_wstrlen(argv[1]));
	StringToGUIDClassName(pBuf, szTemp);
	basic_class_iid.append(pBuf);
#elif (TARGET_OS == OS_POSIX)
	StringToGUIDClassName(argv[1], szTemp);
	basic_class_iid.append(argv[1]);
#elif (TARGET_OS == OS_DARWIN)
	StringToGUIDClassName(argv[1], szTemp);
	basic_class_iid.append(argv[1]);
#endif // MSC_VER

	// {7DADD097-97B4-45ec-A04C-135604FB6934}
	//_DEFINE_GUID(CLSID_CObjectRun,
	//    0x7dadd097, 0x97b4, 0x45ec, 0xa0, 0x4c, 0x13, 0x56, 0x4, 0xfb, 0x69, 0x34);
	basic_class_iid.append("\n");
	basic_class_iid.append("_DEFINE_GUID( <GUID_NAME>,");
	basic_class_iid.append("\n");
	basic_class_iid.append("    ");
	basic_class_iid.append(szTemp);
	basic_class_iid.append(")");
	basic_class_iid.append("\n");
	debug_view(basic_class_iid.c_str());
	return 1;
}

#if (TARGET_OS == OS_POSIX)

int main(int argc, char* argv[])
{
	_pinstance hInstance = INSNULL;
	return main_t(hInstance, argc, argv);
}

#elif (TARGET_OS == OS_DARWIN)

int main(int argc, char* argv[])
{
	_pinstance hInstance = INSNULL;
	return main_t(hInstance, argc, argv);
}

#elif (TARGET_OS == OS_WINDOWS)

int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow) {

	int iRet = 0;
	int nArgs = 0;
	LPWSTR* szArglist = NULL;
	szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
	iRet = main_t(hInstance, nArgs, szArglist);
	LocalFree(szArglist);
	return 1;
}
#endif
